<template>
	<view class="logistics-recive">

		<!-- 加载动画 -->
		<loading ref="loading" :custom="false" :shadeClick="true" :type="1" :shadeShow="false">
		</loading>

		<uni-popup ref="popup2" backgroundColor="#f0f0f0" style="z-index: 999;" :mask-click="false">
			<view class="logistics-recive-popup-modal">
				<view class="logistics-recive-popup-modal-content">
					<view class='logistics-recive-popup-modal-content-option'>

						<text style="padding-left: 32rpx;color: #888888;" @click="close1">取消</text>

						<text style="padding-right: 32rpx;color: #1177e5;" @click="confirmChoice">确定</text>
					</view>
					<view class="logistics-recive-popup-modal-content-box">
						<view class="logistics-recive-popup-modal-content-box-item">
							<image v-if="!value.checked" src="../../static/wdx.png"></image>
							<image v-if="value.checked" src="../../static/dx.png"></image>
							<text>是</text>
						</view>
						<view class="logistics-recive-popup-modal-content-box-item">
							<image v-if="!value.checked" src="../../static/wdx.png"></image>
							<image v-if="value.checked" src="../../static/dx.png"></image>
							<text>否</text>
						</view>
					</view>
				</view>
			</view>
		</uni-popup>
		<!-- 搜索框 -->
		<view class="logistics-recive-search-top">
			<view class="logistics-recive-search-top-left">
				<image src="../../static/search.png" mode=""></image>
				<input type="text" v-model="search" confirm-type="search" @confirm="getSearch" placeholder="请输入搜索内容" />

				<button type="button" class="logistics-recive-search-top-left-btn" @click="getSearch">搜索</button>

			</view>
			<view class="logistics-recive-search-top-scan" @click="scan">
				<image src="../../static/scan.png" mode=""></image>
			</view>
		</view>

		<!-- 时间 -->
		<view class="logistics-recive-datepicker">
			<view class="logistics-recive-datepicker-title">时间:</view>
			<view class="start_date">

				<picker mode="date" :value="start_date" @change="bindDateChange" :end="other"  style="width: 100%;">

					<view class="" style="display: flex;align-items: center;">
						<view class="date">{{start_date}}</view>
						<image src="/static/xia.png">
					</view>
				</picker>

			</view>
			<view class="logistics-recive-datepicker-line">-</view>
			<view class="start_date">

				<picker mode="date" :value="end_date" @change="bindDateChange2" :end="other"  style="width: 100%;">

					<view class="" style="display: flex;align-items: center;">
						<view class="date">{{end_date}}</view>
						<image src="/static/xia.png">
					</view>
				</picker>


			</view>
		</view>
		<!-- 内容区域 -->
		<view class="logistics-recive-container" style="flex: 1;overflow: auto;">
			<!-- 列表 -->
			<view class="logistics-recive-container-list" v-for="(item,index) in list" :key='index'
				:class="item.checked?'active':''">

				<view class="logistics-recive-container-list-content" @click="changeCheck(index)">

					<view>受检者姓名: {{item.patientName || ''}}</view>
					<view>样品编号: {{item.sampleCode || ''}}</view>
					<view>送样状态: {{item.sampleSendStatus || ''}}</view>
					<view>样品类型: {{item.sampleTypeName || ''}}</view>
					<view>检测项目: {{item.productNames || ''}}</view>
					<view>送检医院: {{item.sendHospital || ''}}</view>
					<view>样品备注: {{item.sampleRemark || ''}}</view>
				</view>
				<view class="logistics-recive-container-list-arrows" @click="toSamplesReceivedDetil(item)">

					<image src="/static/arrow2.png" mode="" class="image"></image>
				</view>
			</view>
			<!-- </checkbox-group> -->
		</view>
		<!-- 底部按钮 -->
		<view class="logistics-recive-bottom">
			<view class="logistics-recive-bottom-total">
				<view class="count">

					{{count}}

				</view>

				<checkbox-group @change="allChoose">
					<label>

						全选 <checkbox value="all" :checked="allCheck?true:false"

							color="#0f90d1" style="padding-left: 20rpx;">
						</checkbox>
					</label>
				</checkbox-group>
			</view>
			<view @click="showDrawer" class="logistics-recive-bottom-btn">实验室</view>
			<view @click="open12" class="logistics-recive-bottom-btn">样本接收</view>

		</view>

		 <!-- 提交弹出框 -->
		<uni-popup ref="popup" backgroundColor="#f0f0f0" class="popup">
			<view class="logistics-recive-input" style="height: 40rpx;">
				<view class="logistics-recive-input-lable">
					<text></text>

				</view>

			</view>
			<view class="logistics-recive-input">
				<view class="logistics-recive-input-lable">
					<text>样本状态</text>
					<text class="logistics-recive-input-lable-requie">*</text>
				</view>
				<input placeholder="请输入样本状态" v-model="submitparans.state" placeholder-style="color: rgba(35,39,55,0.3);"/>

				<image src="../../static/warning.png" mode="" v-if="inputState && (submitparans.state=='')"></image>
			</view>
			<view class="logistics-recive-input">
				<view class="logistics-recive-input-lable">
					<text>样本接收温度</text>
					<text class="logistics-recive-input-lable-requie">*</text>
				</view>

				<input placeholder="请输入包裹温度" v-model="submitparans.T" placeholder-style="color: rgba(35,39,55,0.3);"/>

				<image src="../../static/warning.png" mode="" v-if="inputState && (submitparans.T == '')"></image>
			</view>
			<view class="logistics-recive-input">
				<view class="logistics-recive-input-lable">
					<text>样本数量</text>
					<text class="logistics-recive-input-lable-requie">*</text>
				</view>
			
				<input placeholder="请输入包裹温度" v-model="submitparans.count" placeholder-style="color: rgba(35,39,55,0.3);"/>
			
				<image src="../../static/warning.png" mode="" v-if="inputState && (submitparans.count == '')"></image>
			</view>
			<view class="logistics-recive-input">
				<view class="logistics-recive-input-lable">
					<text>是否为公司耗材</text>
					<text class="logistics-recive-input-lable-requie">*</text>
				</view>
				<input @click="openSelect1" placeholder="请选择是否为公司耗材" disabled :value="submitparans.companyMat" placeholder-style="color: rgba(35,39,55,0.3);"/>
				<img @click="openSelect1" src="../../static/选择器展开.png" alt="">
				<image src="../../static/warning.png" mode="" v-if="inputState && (submitparans.companyMat == '')"></image>
			</view>
			<view class="logistics-recive-input">
				<view class="logistics-recive-input-lable">
					<text>样本接收异常信息</text>
				</view>
				<input @click="openSelect2" placeholder="请输入异常信息" disabled :value="submitparans.abnormal" placeholder-style="color: rgba(35,39,55,0.3);"/>
				<img @click="openSelect2" src="../../static/选择器展开.png" alt="">
			</view>
			<view class="logistics-recive-textarea" style="min-height: 80rpx;">
				<view class="logistics-recive-input-lable">
					<text>样本接收备注</text>
				</view>
				<view class="">

					<textarea auto-height   placeholder-style="color: rgba(35,39,55,0.3);" placeholder="请输入样本接收备注"
						:style="{color:`${remark=='' && 'rgba(35,39,55,0.3)'}`}" v-model="submitparans.remark" />
				</view>

			</view>
			<view class="logistics-recive-input" style="border: none;">
				<view class="logistics-recive-input-lable" style="width: auto;">
					<text>附件上传(支持上传多个文件)</text>
					<text class="logistics-recive-input-lable-requie">*</text>
				</view>

			</view>

			<view style="padding: 16rpx 0;margin: 0 20rpx;" @click.stop="fresh=0">
				<uni-file-picker :image-styles="{width:'170rpx',height:'170rpx'}" fileMediatype="image" mode="grid" @select="selectImg" ref="files" @delete="delImg" v-model="imgValue" :auto-upload="false">
					<image style="width: 60rpx;height: 60rpx;" src="../../static/tj.png"></image>
				</uni-file-picker>
			</view>
			<!-- 提交按钮 -->
			<view class="logistics-recive-submit">
				<view
					style="width: 100%;height: 100%;display: flex;justify-content: space-between;align-items: center;padding: 0 36rpx;">
					<view @click="cancel" class="logistics-recive-submit-button2">取消</view>
					<view @click="submit" class="logistics-recive-submit-button3">提交
					</view>
				</view>

			</view>
		</uni-popup>
		
		<!-- 是否耗材弹出框 -->
		<uni-popup ref="popup1" type="bottom">
			<view class="box1">
				<view class="box1-title">
					请选择是否耗材
				</view>
				<view class="box1-content">
					<view class="box1-content-box">
						<radio-group @change="radioChange">
							<view style="padding: 10rpx 0;" v-for="(item, index) in pullDown1" :key="index">
								<label>
									<radio :value="item.text" :checked="item.checked"/>{{item.text}}
								</label>
							</view>
						</radio-group>
					</view>
				</view>
				<view class="box1-bottom">
					<button type="primary" size="mini" @click="closePopup1">关闭</button>
					<button type="primary" size="mini" @click="okPopup1">确定</button>
				</view>
			</view>
		</uni-popup>
		
		<!-- 样本接收异常弹出框 -->
		<uni-popup ref="popup2" type="bottom">
			<view class="box1">
				<view class="box1-title">
					请选择异常信息
				</view>
				<view class="box1-content">
					<view class="box1-content-box">
						<checkbox-group @change="checkboxChange">
							<view style="margin: 10rpx 0;" v-for="(item, index) in pullDown2" :key="index">
								<label>
									<checkbox :value="item.text" /> {{item.text}}
								</label>
							</view>
						</checkbox-group>
					</view>
				</view>
				<view class="box1-bottom">
					<button type="primary" size="mini" @click="closePopup2">关闭</button>
					<button type="primary" size="mini" @click="okPopup2">确定</button>
				</view>
			</view>
		</uni-popup>
		<!-- 侧边抽屉 -->
		<!-- 实验室抽屉 -->
		<uni-drawer ref="showRight" mode="right" :mask-click="false">
			<scroll-view style="height: 100%;display: flex;flex-direction: column;" scroll-y="true" enable-flex="true">
				<view class="drawer-box">
					<view v-for="(item,index) in las" :key="item" @click="choiceLab(item)"
						:class="item.check==true?'select':''">{{ item.name }}</view>
				</view>
				<!-- <button @click="closeDrawer" type="primary" class="drawer-btn" style="margin-bottom: 40rpx;">确定</button> -->
			</scroll-view>
		</uni-drawer>
	</view>
</template>

<script>

	import baseUrl from '../../utils/config.js'
	import loading from '../../components/xuan-loading/xuan-loading.vue'
	export default {
		components: {
			loading
		},

		data() {
			const currentDate = this.getDate({
				format: true
			})
			const beforeDate = this.getBeforeDate({
				format: true
			})
			return {
				sampleReceivingShow: false,
				imgValue:[],
				sampleReceivingShow2: false,
				inputState: false,
				statusIndex: -1,
				normalList: [],
				list: [],
				listCopy:[],
				listlabsamples:[],
				start_date: beforeDate,
				end_date: currentDate,
				other: currentDate,
				allCheck: false,
				addnormalArray: [],
				addText: '',
				filesPath:[],
				search:'',
				fresh:1,
				submitFlag:1,
				count:0,
				// 提交参数
				submitparans: {
					state: '',    // 状态
					T: '',        // 温度
					count: '',	  // 样本数量
					companyMat: '',    // 是否公司耗材
					remark: '',   // 备注
					abnormal: "", // 异常信息
				},
				pullDown2: [], // 异常信息字段值下拉选项
				pullDown1: [], // 是否为公司耗材下拉选项，字典编码：companyMat
				las:[] ,//所有实验室
				lab:'' //当前选择的实验室
			};
		},
		onLoad() {
			// 获取下拉数据
			this.pullDownData1()
			this.pullDownData2()
			this.$refs.showRight.open();
			
			// console.log('调用onLoad');
		},
		onShow() {

			if(this.fresh==1){
				this.count=0;
				this.allCheck=false
				this.getShowData()
				// this.showDrawer()
			}
			// this.getShowData()
			
			this.fresh==1
		},
		methods: {
			close:function(){
				this.$refs.loading.close();
			},
			open:function(){
				this.$refs.loading.open();
			},
			showDrawer(){
				// 打开抽屉，将所有全部实验室为未选中状态
				// this.las = this.las.map(item=>{
				// 	item.check = false
				// 	return item 
				// })
				this.$refs.showRight.open();
			},
			// 关闭抽屉获取所有选的实验室
			// closeDrawer(){
			// 	this.$refs.showRight.close();
			// 	// 获取所有被选择的实验室
			// 	let las = this.las.map(item=>{
			// 		if(item.check){
			// 			return item.name
			// 		}else{ return 0}
			// 	}).filter(item=>{
			// 		return item != 0
			// 	})
			// 	// 获取所有选择实验室的样本
			// 	this.listlabsamples = this.listCopy.filter(item=>{
			// 		 if( las.indexOf(item.orgName) != -1){
			// 			 return item
			// 		 }
			// 	})
			// 	// 需要更新list的内容为 选择的实验室的所有样本
			// 	this.list = this.listlabsamples
			// },
			// 获取数据中的所有实验室
			selectLab(){
				// 每次showdata 都获取当前las 的长度 然后对比listCopy
			let count = this.las.length
				// 取出送检实验室
			 let lascopy = this.listCopy.map(item => {
					return item.orgName
				})
				// 过滤重复项 string类型的
				
				let alllas = lascopy.filter(function(item,index){
				 return lascopy.indexOf(item) === index;   
			  })
			  // 将所有的 实验室已对象形式返回
			  this.las = alllas.map(item=>{
			  		return {name:item ,check:false}
			  })
			},
			// 选择的实验室
			choiceLab(val){
				// 将当前的改为选中状态
				val.check = true
				this.lab = val.name
				// 将其他的改为全部为 false 
				this.las.forEach(item=>{
					if(item.name != val.name){
						item.check = false
					}
				})
				// 获取选中实验室的样本到list 页面  和 listlassamples
				
				// 获取所有选择实验室的样本
				this.listlabsamples = this.listCopy.filter(item=>{
					 if(item.orgName == val.name){
						 return item 
					 }
				})
				// 需要更新list的内容为 选择的实验室的所有样本
				this.list = this.listlabsamples
				this.allCheck = false
				this.count = 0
				this.$refs.showRight.close();
			},
			// 弹出耗材
			openSelect1() {
				this.$refs.popup1.open()
			},
			
			// 弹出异常信息
			openSelect2() {
				this.$refs.popup2.open()
			},
			
			// 关闭耗材弹框
			closePopup1() {
				this.submitparans.companyMat = ''
				this.$refs.popup1.close()
			},
			
			// 确定->关闭弹框
			okPopup1() {
				this.$refs.popup1.close()
			},
			
			// 关闭异常信息弹框
			closePopup2() {
				this.submitparans.companyMat = ''
				this.$refs.popup2.close()
			},
			
			// 确定->关闭弹框
			okPopup2() {
				this.$refs.popup2.close()
			},
			
			// 当前选中耗材
			radioChange(e) {
				this.submitparans.companyMat = e.detail.value
				
			},
			
			// 当前选中的异常信息
			checkboxChange(e) {
				this.submitparans.abnormal = e.detail.value.toString()
			},
			
			//搜索功能
			getSearch() {
				let start_date = new Date(this.start_date).getTime();
				let end_date = new Date(this.end_date).getTime();
				let keyWord = this.search.replace(/\s*/g, "");
				let time;
				this.list = [];
				if (keyWord == '' || keyWord == undefined) {
					for (let i = 0; i < this.listlabsamples.length; i++) {
						time = new Date(this.listlabsamples[i].pickUpTime).getTime();
						if (time >= start_date && time <= end_date) {
							this.list.push(this.listlabsamples[i])
						}
					};
				} else {
					let reg = new RegExp(keyWord);
					this.listlabsamples.map((el, index) => {
						time = new Date(el.pickUpTime).getTime();
						for (let key in el) {
							if (typeof el[key] == 'object') {
								continue;
							} else {
			
								el[key] = el[key].toString();
								if (el[key].match(reg) && time >= start_date && time <= end_date) {
									this.list.push(el);
									break;
								}
							}
			
			
						}
					})
				}
				this.list.map(el => {
					el.checked = false
				})
			},
			// 获取数据
			getShowData(){
				let that=this;
	
				let url = 'applets/query/sampleReceive';
				// uni.showLoading({
				// 	title: '加载中'
				// });
				that.open();
				uni.request({
					url: baseUrl + url,
					data: {},
					//formdate格式
					header: {
						"Content-Type": "application/json",
						'token': uni.getStorageSync('token')
					},
					method: "POST",
					success: (res) => {
						
						// uni.hideLoading();
						that.close();
						if (res.data.status == 200) {
							res.data.data.forEach((el) => {
								el.pickUpTime = el.pickUpTime.split(" ")[0]
							})
							this.list=[];
							this.listCopy=[];
							
							for(let i=0;i<res.data.data.length;i++){
								res.data.data[i].checked = false;
								// that.list.push(res.data.data[i])
								that.listCopy.push(res.data.data[i])
							}
								// 将所有获取到的实验室保存
								this.selectLab()
								// 不为空表示有数据
								
								if(that.lab){
									that.list = that.listCopy.filter(item=>{
										if(that.lab == item.orgName){
											return item 
										}
									})
									that.listlabsamples = that.list
								}
							// that.list = res.data.data;
						} else if (res.data.status == 401) {
							uni.showToast({
								title: 'token过期，请重新登录',
								duration: 2000,
								icon: 'none'
							});
							uni.redirectTo({
								url: '../index/index'
							})
						} else {
							let msg = res.data.msg
							uni.showToast({
								title: msg,
								duration: 2000,
								icon: 'none'
							});
						}
					},
					fail: (res) => {
						// uni.hideLoading();
						that.close();
						uni.showToast({
							title: '连接错误，请检查网络设置',
							duration: 2000,
							icon: 'none'
						});
					},
					
				});
				
			},
			
			// 异常信息字段值下拉选项
			pullDownData2() {
				let that = this;
				let url = 'common'
				uni.request({
					url: baseUrl + url,
					data: {
						type: 'abnormalReason,normalReason'
					},
					//formdate格式
					header: {
						"Content-Type": "application/x-www-form-urlencoded",
						'token': uni.getStorageSync('token')
					},
					method: "GET",
					success: (res) => {
			
						if (res.data.status == 200) {
							console.log(res.data)
							res.data.ext$.rows.forEach(el=>{
								let tempObject={};
								tempObject.text=el;
								tempObject.checked=false
								that.pullDown2.push(tempObject);
							})
							console.log(that.pullDown2)
						} else if (res.data.status == 401) {
							uni.showToast({
								title: 'token过期，请重新登录',
								duration: 2000,
								icon: 'none'
							});
							uni.redirectTo({
								url: '../index/index'
							})
						} else {
							let msg = res.data.msg
							uni.showToast({
								title: msg,
								duration: 2000,
								icon: 'none'
							});
						}
					},
					fail: (res) => {
						uni.hideLoading();
						uni.showToast({
							title: '连接错误，请检查网络设置',
							duration: 2000,
							icon: 'none'
						});
					}
				});
			},
			
			// 是否为公司耗材下拉选项，字典编码：companyMat
			pullDownData1() {
				let that = this;
				let url = 'common'
				uni.request({
					url: baseUrl + url,
					data: {
						type: 'companyMat'
					},
					//formdate格式
					header: {
						"Content-Type": "application/x-www-form-urlencoded",
						'token': uni.getStorageSync('token')
					},
					method: "GET",
					success: (res) => {
			
						if (res.data.status == 200) {
							res.data.ext$.rows.forEach(el=>{
								let tempObject={};
								tempObject.text=el;
								tempObject.checked=false
								that.pullDown1.push(tempObject);
							})
							console.log(that.pullDown1)
							
						} else if (res.data.status == 401) {
							uni.showToast({
								title: 'token过期，请重新登录',
								duration: 2000,
								icon: 'none'
							});
							uni.redirectTo({
								url: '../index/index'
							})
						} else {
							let msg = res.data.msg
							uni.showToast({
								title: msg,
								duration: 2000,
								icon: 'none'
							});
						}
					},
					fail: (res) => {
						uni.hideLoading();
						uni.showToast({
							title: '连接错误，请检查网络设置',
							duration: 2000,
							icon: 'none'
						});
					}
				});
			},
			
			// 跳转详情
			toSamplesReceivedDetil(item) {
				let data={
					item:item,
					normalList:this.normalList
				}
				data=JSON.stringify(data);
				uni.navigateTo({
					url: `../samplesReceivedDetil/samplesReceivedDetil?data=${JSON.stringify(item)}`

				})
			},
			// 选择日期
			bindDateChange: function(e) {

				if (new Date(e.target.value).getTime() > new Date(this.end_date).getTime()) {
					uni.showToast({
						title: '选择时间范围错误',
						duration: 2000,
						icon: 'none'
					});
					return
				}
				this.start_date = e.target.value
			},
			bindDateChange2: function(e) {
				if (new Date(e.target.value).getTime() < new Date(this.start_date).getTime()) {
					uni.showToast({
						title: '选择时间范围错误',
						duration: 2000,
						icon: 'none'
					});
					return
				}
				this.end_date = e.target.value;
			},
			// 选择图片
			selectImg(e){
				let count=0;
				uni.showLoading({
					title:'图片上传中'
				})
				let that = this;
				
				for (let i = 0; i < e.tempFiles.length; i++) {
					this.imgValue.push(e.tempFiles[i])
				}
				// 判断是否有图片
				if (this.imgValue.length !== 0) {
					for (let i = 0; i < this.imgValue.length; i++) {
						if (that.imgValue[i].path == undefined || (that.imgValue[i].path.indexOf(
								'data:image/png;base64,') != -1) || (that.imgValue[i].path
								.indexOf('data:image/jpeg;base64,') != -1)) {
							continue;
						}
						// 转base64
						wx.getFileSystemManager().readFile({
							filePath: that.imgValue[i].path, //要读取的文件的路径 (本地路径)
							encoding: "base64", //指定读取文件的字符编码，如果不传 encoding，则以 ArrayBuffer 格式读取文件的二进制内容
							success: function(res) {
								if (that.imgValue[i].extname === 'png') {
									that.imgValue[i].path = 'data:image/png;base64,' + res.data;
								} else {
									that.imgValue[i].path = 'data:image/jpeg;base64,' + res.data;
								}
								count++;
								if(count==e.tempFiles.length){
									uni.hideLoading()
								}
							},
							fail: function(res) {
								uni.showToast({
									title: '图片转换失败，请重新上传',
									duration: 2000,
									icon: 'none'
								});
								count++;
								if(count==e.tempFiles.length){
									uni.hideLoading()
								}
							}
						})
					}
				
				}
				// this.fresh=1;
			},
			// 删除图片
			delImg(e){
			for (let i = 0; i < this.imgValue.length; i++) {
				if (e.tempFile.uuid == this.imgValue[i].uuid) {
					this.imgValue.splice(i, 1)
				}
			
			
			}

			},
			abnormalChoice() {
				this.$refs.popup.close();
				this.$refs.popup2.open('bottom');
			},
			// 获取当前时间
			getDate(type) {
				const date = new Date();
				let year = date.getFullYear();
				let month = date.getMonth() + 1;
				let day = date.getDate();
				if (type === 'start') {
					year = year - 60;
				} else if (type === 'end') {
					year = year + 2;
				}
				month = month > 9 ? month : '0' + month;;
				day = day > 9 ? day : '0' + day;
				return `${year}-${month}-${day}`;
			},
			//获取七天前时间
			getBeforeDate(type) {
				const date = new Date();
				var sevenDayMilliseconds = date.getTime() - 1000 * 60 * 60 * 24 * 7;
				date.setTime(sevenDayMilliseconds);
				let year = date.getFullYear();
				let month = date.getMonth() + 1;
				let day = date.getDate();
				if (type === 'start') {
					year = year - 60;
				} else if (type === 'end') {
					year = year + 2;
				}
				month = month > 9 ? month : '0' + month;;
				day = day > 9 ? day : '0' + day;
				return `${year}-${month}-${day}`;
			},

			open12() {
				let open=false;
				for(let i=0;i<this.list.length;i++){
					if(this.list[i].checked){
						open=true;
						break;
					}
				}
				if (open) {
					this.$refs.popup.open('bottom')
				} else {
					uni.showToast({
						title: '请选择快递单',
						duration: 2000,
						icon: 'none'
					});
					return;
				}

			},

			// 对话框取消按钮
			cancel() {
				this.submitparans.state = ''
				this.submitparans.T = ''
				this.submitparans.count = ''
				// this.submitparans.companyMat = ''
				// this.submitparans.abnormal = ''
				this.submitparans.remark = ''
				 this.imgValue = ''
				this.$refs.popup.close()
			},
			//全选
			allChoose() {

				for (var i = 0; i < this.list.length; i++) {
					this.list[i].checked == false
				}
				this.count=0;
				if (this.allCheck == false) {
					this.list.map(item => this.$set(item, 'checked', true));
					this.allCheck = true;
					this.count=this.list.length;
					
				} else {
					this.list.map(item => this.$set(item, 'checked', false));
					this.allCheck = false;
				}
			},
			// 多选
			changeCheck(index) {
				let count=0;
				if (this.list[index].checked == true) {
					this.list[index].checked = false;
					for (var i = 0; i < this.list.length; i++) {
						if (this.list[i].checked == true)
							count++;
					}
				} else {
					this.list[index].checked = true;
					for (var i = 0; i < this.list.length; i++) {
						if (this.list[i].checked == true)
							count++;
					}
				}
				// 如果选择的数组中有值，并且长度等于列表的长度，就是全选
				if (count == this.list.length) {

					this.allCheck = true;
				} else {
					this.allCheck = false;
				}

				this.count=count;
				



			},
			
			// 扫码
			scan() {
				let that=this
				uni.scanCode({
					success: function(res) {
						that.search=res.result;
					}
				});
			},
			
			selectModalItem(val) {
				this.normalList = this.normalList.map(element => {
					if (val === element) {
						element.checked = !element.checked;
					}
					return element;
				})
			},
			// 重点关注取消

			close1() {
				for(let i=0;i<this.normalList.length;i++){
						this.normalList[i].checked=false;
				}
				for (let j = 0; j < this.addnormalArray.length; j++) {
					for(let i=0;i<this.normalList.length;i++){
						if(this.normalList[i].text==this.addnormalArray[j]){
							this.normalList[i].checked=true;
						}
					}
				}

				this.$refs.popup2.close();
				this.$refs.popup.open('bottom');
			},
			// 加测项目确认
			confirmChoice() {
				this.addnormalArray = [];

				this.addText='';
				for (let i = 0; i < this.normalList.length; i++) {
					if (this.normalList[i].checked) {
						this.addnormalArray.push(this.normalList[i].text);
					}
				}
				for (let j = 0; j < this.addnormalArray.length; j++) {
					if (j == this.addnormalArray.length - 1) {
						this.addText += this.addnormalArray[j]
					} else {
						this.addText += this.addnormalArray[j] +
							','
					}
				}
				this.$refs.popup2.close();
				this.$refs.popup.open('bottom');
			},

			// 提交
			submit() {
			if(this.submitFlag==1){
				this.submitFlag=0;
				if ( this.imgValue.length == 0 || this.submitparans.state == '' || this.submitparans.t == '' || this.submitparans.count == '' || this.submitparans.companyMat == '') {
					this.inputState = true;
				}
				if (this.submitparans.state == '') {
					uni.showToast({
						title: '请输入样本状态',
						duration: 2000,
						icon: 'none'
					});

					this.submitFlag=1;
					return;
				}
				if (this.submitparans.t == '') {
					uni.showToast({
						title: '请输入样本接收温度',
						duration: 2000,
						icon: 'none'
					});

					this.submitFlag=1;
					return;
				}
				if (this.submitparans.count == '') {
					uni.showToast({
						title: '请输入样本数量',
						duration: 2000,
						icon: 'none'
					});
				
					this.submitFlag=1;
					return;
				}
				if (this.submitparans.companyMat == '') {
					uni.showToast({
						title: '请选择是否公司耗材',
						duration: 2000,
						icon: 'none'
					});
				
					this.submitFlag=1;
					return;
				}
				if (this.imgValue.length == 0) {
					uni.showToast({
						title: '请上传附件',
						duration: 2000,
						icon: 'none'
					});
					this.submitFlag=1;
					return;
				}
				let expressNumberList=[];
				this.list.forEach((el)=>{
					if(el.checked==true){
						expressNumberList.push(el.sampleId)
					}
				})
				console.log("选中的数据",expressNumberList)
				let that=this;
				let logisticsUrls1 = [];
				for (let i = 0; i < this.imgValue.length; i++) {
					logisticsUrls1[i] = {}
					if (this.imgValue[i].path == undefined) {
						logisticsUrls1[i].url = this.imgValue[i].url;
						logisticsUrls1[i].id = this.imgValue[i].id;
					} else {
						logisticsUrls1[i].url = this.imgValue[i].path;
					}
				
					logisticsUrls1[i].name = this.imgValue[i].name;
				}
				console.log("上传的文件",logisticsUrls1)
				let data={
						sampleIdList: expressNumberList,
						sampleStatus: that.submitparans.state,
						temperature: that.submitparans.T,
						sampleNumber: that.submitparans.count,
						companyMat: that.submitparans.companyMat,
						abnormalReason: that.submitparans.abnormal,
						remark: that.submitparans.remark,
						sampleUrls:logisticsUrls1
					};
				
					// return;
					that.open();
					let url='applets/submit/sampleReceive';
				uni.request({
					url: baseUrl + url,
					data: data,
					header: {
						"Content-Type": "application/json",
						'token': uni.getStorageSync('token')
					},
					method: "POST",
					success: (res) => {
						that.close();
						if (res.data.status == 200) {
							that.addText='';
							that.remark='';
							that.imgValue=[];
							that.addnormalArray=[];
							that.count=0;
							that.normalList.forEach(el=>{
								el.checked=false;
							})
							that.pullDown1.forEach(item=>{
								item.checked = false
							})
							that.pullDown2.forEach(item=>{
								item.checked = false
							})
							that.submitparans.state = ''
							that.submitparans.T = ''
							that.submitparans.count = ''
							that.submitparans.companyMat = ''
							that.submitparans.abnormal = ''
							that.submitparans.remark = ''
							uni.showToast({
								title: '提交成功',
								duration: 2000,
								icon: 'none',
								success:function(){
									that.submitFlag=1;
									that.getShowData();

									
								}
							});
							
							this.$refs.popup.close();
						}  else if (res.data.status == 401) {
							uni.showToast({
								title: 'token过期，请重新登录',
								duration: 2000,
								icon: 'none',
								success:function(){
									that.submitFlag=1;
								}
							});
							uni.redirectTo({
								url: '../index/index'
							})
						}
						else {
							let msg=res.data.msg
							if (msg != undefined) {
								uni.showToast({
									title: msg,
									duration: 2000,
									icon: 'none',
									success:function(){
										that.submitFlag=1;
									}
								});
							} else {
								uni.showToast({
									title: '服务器故障',
									duration: 2000,
									icon: 'none',
									success:function(){
										that.submitFlag=1;
									}
								});
							}
						}
					},
					fail: (res) => {
						that.close();
						uni.showToast({
							title: '连接错误，请检查网络设置',
							duration: 2000,
							icon: 'none',
							success:function(){
								that.submitFlag=1;
							}
						});
					}
				});
			}

			}
		}
	}
</script>

<style lang="scss">
	.drawer-box {
		display: flex;
		flex-wrap: wrap;
		margin-bottom: 100px;
	}

	.drawer-box view {
		display: flex;
		align-items: center;
		justify-content: center;
		background-color: rgb(242, 242, 242);
		margin-top: 30rpx;
		border-radius: 30rpx;
		padding: 20rpx 40rpx;
		font-size: 28rpx;
		margin-left: 20rpx;
		letter-spacing: 1rpx;
		font-weight: 300;
		box-sizing: border-box;
		border: 1rpx solid white;
	}

	.drawer-box .select {
		background-color: rgb(251, 238, 232);
		color: #15b1bd;
		border: 0.01rem solid #15b1bd;
	}

	.drawer-btn {
		width: 80%;
		border-radius: 30rpx;
		position: fixed;
		    bottom: 0;
		    left: 10%;
		background-image: linear-gradient(to right, #15b1bd, #1095cd);
	}
	.info {
		padding: 15px;
		color: #666;
	}
	
	.info-text {
		font-size: 14px;
		color: #666;
	}
	.info-content {
		padding: 5px 15px;
	}
	.close {
		padding: 10px;
	}
	.box1{
		width: 100%;
		height: 800rpx;
		background-color: #fff;
		display: felx;
		flex-direction: column;
		&-title{
			font-size: 40rpx;
			text-align: center;
			height: 100rpx;
			line-height: 100rpx;
		}
		&-bottom{
			display: flex;
			justify-content: space-between;
		}
		&-content{
			height: 600rpx;
			overflow: scroll;
			margin-bottom: 20rpx;
			padding: 20rpx 30rpx;
			display: flex;
			justify-content: center;
		}
	}
	
	.logistics-recive {
		width: 100vw;
		height: 100vh;
		display: flex;
		flex-direction: column;
		font-size: 32rpx;
		background-color: #f0f0f0;

		&-popup-modal {

			image {
				width: 40rpx;
				height: 40rpx;
			}

			&-content {
				background-color: white;
				height: 700rpx;
				width: 100%;
				// position: absolute;
				transition-duration: 0.3s;
				border-radius: 20rpx 20rpx 0 0;

				&-option {
					display: flex;
					justify-content: space-between;
					height: 90rpx;
					border-bottom: #f6f6f6 1px solid;
					font-size: 32rpx;

					text {
						height: 100%;
						display: flex;
						align-items: center;
						letter-spacing: 2rpx;
					}

				}

				&-box {
					display: flex;
					flex-direction: column;
					height: 610rpx;
					width: 100%;
					overflow-y: auto;
					padding: 32rpx 0;

					&-item {
						display: flex;
						height: 80rpx;
						flex-shrink: 0;
						flex-grow: 0;
						padding-left: 50rpx;
						align-items: center;
						font-size: 30rpx;

						image {
							height: 50rpx;
							width: 50rpx;
							margin-right: 24rpx;
						}
					}
				}
			}

			&-mask {
				width: 100%;
				height: 100%;
				background-color: rgba(0, 0, 0, 0.5);
			}
		}

		&-search-top {
			display: flex;
			align-items: center;
			margin: 20rpx;
			height: 60rpx;

			&-left {
				flex: 1;
				background-color: #fff;
				display: flex;
				align-items: center;
				height: 100%;
				border-radius: 30rpx;

				image {
					width: 40rpx;
					height: 40rpx;
					padding: 0 20rpx;
				}

				input {
					flex: 1;
				}

				&-btn {
					width: 150rpx;
					color: #689ae3;
					font-size: 32rpx;
					height: 100%;
					display: flex;
					align-items: center;
					justify-content: center;
					margin: 0;
					outline: none;
					background-color: #fff;
				}
			}

			&-scan {
				margin: 0 20rpx;

				image {
					width: 50rpx;
					height: 50rpx;
				}
			}

			button::after {
				border: none;
			}
		}

		// 弹窗样式
		&-input {
			display: flex;
			height: 80rpx;
			align-items: center;
			padding-right: 40rpx;
			font-size: 32rpx;
			border-bottom: 1rpx dotted #C0C0C0;
			margin: 0 20rpx;

			image {
				width: 30rpx;
				height: 30rpx;
			}

			&-lable {
				margin: 0 20rpx;
				width: 290rpx;

				&-requie {
					color: red;
				}

			}

			&-upload {
				width: 100rpx;
				border: 1px solid #ccc;
				border-radius: 15rpx;
				background-color: #ccc;
				align-items: center;
				justify-content: center;
				display: flex;
			}

			input {
				flex: 1;


			}

			&-picker-content {
				display: flex;
				align-items: center;

				image {
					padding-left: 10rpx;
				}
			}

		}

		&-textarea {
			display: flex;
			min-height: 80rpx;
			align-items: center;
			padding-right: 40rpx;
			font-size: 32rpx;
			border-bottom: 1rpx dotted #C0C0C0;
			margin: 0 20rpx;

			textarea {

				width: 340rpx;
			}
		}

		// .button-bottom {
		// 	height: 80rpx;
		// 	display: flex;
		// 	align-items: center;

		// 	.popup-btn {
		// 		height: 100%;
		// 		width: 50%;
		// 		display: flex;
		// 		align-items: center;
		// 		justify-content: center;

		// 		button {
		// 			height: 100%;
		// 			width: 200rpx;
		// 			border: none;
		// 			border-radius: 0;
		// 			outline: none;
		// 			background-color: #fff;
		// 			padding: 0;
		// 			margin: 0;
		// 			font-size: 32rpx;
		// 		}

		// 		button::after {
		// 			border: none;
		// 		}
		// 	}

		// }

		&-search-top {
			display: flex;
			align-items: center;
			margin: 20rpx;
			height: 60rpx;

			&-left {
				flex: 1;
				background-color: #fff;
				display: flex;
				align-items: center;
				height: 100%;
				border-radius: 30rpx;

				image {

					width: 40rpx;
					height: 40rpx;

					padding: 0 20rpx;
				}

				input {
					flex: 1;
				}
			}

			&-btn {
				width: 150rpx;
				color: #689ae3;
				font-size: 32rpx;
				height: 100%;
				display: flex;
				align-items: center;
				justify-content: center;
				margin: 0;
				outline: none;
				background-color: #f0f0f0;
			}

			button::after {
				border: none;
			}


		}

		&-datepicker {
			display: flex;
			margin: 20 0rpx;
			height: 80rpx;
			line-height: 80rpx;
			-webkit-box-align: center;
			-webkit-align-items: center;
			align-items: center;
			padding-left: 40rpx;
			background-color: #fff;

			&-datepicker-title {
				margin-right: 20rpx;
				color: rgba(35, 39, 55, 0.9);
			}

			.start_date {
				width: 260rpx;
				background-color: #f0f0f0;
				display: flex;
				align-items: center;
				height: 60rpx;
				border-radius: 30rpx;

				.date {

					padding-left: 10rpx;
					flex:1;
				}

				image {
					padding-left: 10rpx;
				}

			}

			&-choose {
				display: flex;
			}

			image {
				width: 36rpx;
				height: 36rpx;

				margin-right: 10rpx;
				transition-duration: 0.3s;
			}

			&-line {
				margin: 0 10rpx;
			}

			&-title {
				margin-right: 20rpx;
				color: rgba(35, 39, 55, 0.9);
			}
		}

		&-container {
			&-list {
				display: flex;
				align-items: center;
				background-color: #fff;
				margin: 0 20rpx;
				margin-top: 20rpx;
				padding: 0 20rpx;
				border-radius: 30rpx;
				position: relative;
				border: 6rpx solid #fff;

				&-checkbox {
					margin: 0 30rpx;
				}

				&-content {
					flex: 1;
					width: 75%;
					display: flex;
					flex-direction: column;

					view {
						height: 60rpx;
						line-height: 60rpx;
						overflow: hidden;
						white-space: nowrap;
						text-overflow: ellipsis;
						display: flex;
						align-items: center;
						color: rgba(35, 39, 55, .9);
					}

				}

				&-arrows {

					width: 50rpx;
					height: 50rpx;
					color: #0f90d1;
					border-radius: 50%;
					font-size: 60rpx;
					display: flex;
					justify-content: center;
					align-items: center;
					// color: rgba(35, 39, 55, .5);
					border: 3rpx solid #0f90d1;
					margin-right: 30rpx;
					display: flex;
					align-items: center;
					justify-content: center;


				}

				image {
					width: 40rpx;
					height: 40rpx;
				}
			}

			.active {
				border: 6rpx solid #0f90d1;
			}
		}


		&-bottom {

			height: 100rpx;
			background-color: #f6f7f9;
			display: flex;
			justify-content: space-between;
			align-items: center;

			padding: 0 40rpx;

			&-total {
				display: flex;
				justify-content: center;
				align-items: center;
			}

			&-btn {
				display: flex;
				align-items: center;
				justify-content: center;

				// width: 220rpx;
				width: calc(50% - 180rpx);
				background-image: linear-gradient(to right, #15b1bd, #1095cd);
				color: white;
				border-radius: 45rpx;
				min-height: 76rpx;
			}
		}

		.image {
			width: 30rpx;
			height: 30rpx;
		}

		.logistics-recive-bottom-total {

			display: flex;
			justify-content: center;
			align-items: center;

			.count {
				min-width: 50rpx;
				min-height: 50rpx;
				border-radius: 50%;
				background: #0f90d1;
				color: #fff;
				display: flex;
				align-items: center;
				justify-content: center;
				margin-right: 10rpx;
			}
		}

		.popup {
			color: rgba(35, 39, 55, 0.9);
		}

		&-submit {
			width: 100%;
			height: 100rpx;
			background-color: #f6f7f9;
			display: flex;
			align-items: center;
			justify-content: center;

			&-button2 {
				height: 66rpx;
				width: calc(50% - 36rpx);
				border-radius: 45rpx;
				color: white;
				background-image: linear-gradient(to right, #15b1bd, #1095cd);
				display: flex;
				align-items: center;
				justify-content: center;
				font-size: 30rpx;
				border: 1px solid #bebfc3;
			}

			&-button3 {
				height: 66rpx;
				width: calc(50% - 36rpx);
				background-image: linear-gradient(to right, #15b1bd, #1095cd);
				border-radius: 45rpx;
				color: white;
				display: flex;
				align-items: center;
				justify-content: center;
				font-size: 30rpx;
			}
		}

		.addText {
			/* word-break: keep-all; */
			white-space: nowrap;
			overflow: hidden;
			text-overflow: ellipsis;
			display: inline-block;
			width: 310rpx;
			/* 解决高度变高问题 */
			vertical-align: bottom
		}
	}
</style>
